package com.delayqueue.common.util;

import java.util.Random;

public class RandomUtil {

    private static final char[] chars = {
            '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
            'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'A', 'B',
            'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U',
            'V', 'W', 'X', 'Y', 'Z'
    };
    private static Random ran = new Random();

    public static int random(int max) {
        return ran.nextInt(max);
    }

    public static final String getRandomNum(int numCount) {

        StringBuilder result = new StringBuilder();
        for (int i = 0; i < numCount; i++) {
            result.append(chars[ran.nextInt(10)]);
        }
        return result.toString();
    }

    public static final String getRandomStr(int strLength) {
        StringBuilder result = new StringBuilder();
        int len = chars.length;
        for (int i = 0; i < strLength; i++) {
            result.append(chars[ran.nextInt(len)]);
        }
        return result.toString();
    }

}
